package com.hice.demo.sbdbra.common.util.security;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class SHAUtil {
    private static Logger log = LoggerFactory.getLogger(SHAUtil.class);

    public static byte[] sha(String input) {
        try {
            MessageDigest sha = MessageDigest.getInstance("SHA");
            sha.update(input.getBytes());
            return sha.digest();
        } catch (NoSuchAlgorithmException e) {
            log.error("=======SHA加密失败========");
        }
        return null;
    }

    public static byte[] sha1(String input) {
        try {
            MessageDigest sha = MessageDigest.getInstance("SHA-1");
            sha.update(input.getBytes());
            return sha.digest();
        } catch (NoSuchAlgorithmException e) {
            log.error("=======SHA-1加密失败========");
        }
        return null;
    }
}